﻿using Sustainalytics.Synchronization.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Xunit.Abstractions;

namespace Sustainalytics.ClientDW.Synchronization.RiskRatingsBenchmarks.Tests
{
    [Trait("Category", "RiskRating")]
    public class SyncRiskRatingsBenchmarksSyncStepTests
    {
        private readonly RiskRatingsBenchmarksSyncStep riskRatingsSync = new RiskRatingsBenchmarksSyncStep();

        private readonly ITestOutputHelper output;

        private readonly SyncContext context = new SyncContext(ErrorPolicy.BreakRightAway, (x) => Console.WriteLine(x))
        {
            GAConnectionStrings = new Dictionary<string, string>
            {
                { "ClientDW", "mongodb://localhost:27017/ClientDW_A" },
                { "RiskRatingsResearchDW", "mongodb://localhost:27017/RiskRatingsResearchDW_A" },
            },
            DSOConnectionStrings = new Dictionary<string, string>(),
            Report = new System.Collections.Concurrent.ConcurrentBag<string>(),
            CompanyUniverses = new Dictionary<Guid, List<int>>(),
            PreviousChanges = new List<ChangedElement>(),
        };

        public SyncRiskRatingsBenchmarksSyncStepTests(ITestOutputHelper output)
        {
            this.output = output;
        }

        [Fact]
        public void Start()
        {
            var result = riskRatingsSync.Start(context);
            output.WriteLine(result.Report.ToArray().Aggregate((i, j) => i + Environment.NewLine + j));
        }
    }
}